include( "shared.lua" )
include( "admin_menu.lua" )
include( "inventory_shared.lua" )



function PlayerMenu()
	
	local MainFrame = vgui.Create( "DFrame" )
		MainFrame:SetSize( ScrW() * 0.75, ScrH() * 0.6 )
		MainFrame:Center()
		MainFrame:SetTitle( "Player Menu" )
		MainFrame:SetVisible( true )
		MainFrame:ShowCloseButton( true )
		MainFrame:SetDraggable( false )
		MainFrame:SetSizable( false )
		MainFrame:SetBackgroundBlur( true )
		MainFrame:MakePopup()
		
		
	local MenuSheet = vgui.Create( "DPropertySheet", MainFrame )
		MenuSheet:SetPos( 2, 30 )
		MenuSheet:SetSize( MainFrame:GetWide() - 4, MainFrame:GetTall() - 35 )
		

	local BagP = vgui.Create( "DPanel", MenuSheet )
	local Bag = nil
		BagP:SetPos( 0, 0 )
		BagP:SetSize( MenuSheet:GetWide(), MenuSheet:GetTall() )
		MenuSheet:AddSheet( "Bag", BagP, "gui/silkicons/user", false, false, "Player's item bag" )
		function BagP:Think()
			local TAB = MenuSheet:GetActiveTab():GetValue()
			if !Bag and TAB == "Bag" then
				Bag = vgui.Create( "InvBag", BagP )
					Bag:StretchToParent( 0, 0, 0, 0 )
			elseif Bag and TAB != "Bag" then
				Bag:Remove()
				Bag = nil
			end
		end
		
	local StoreP = vgui.Create( "DPanel", MenuSheet )
	local Store = nil
		StoreP:SetPos( 0, 0 )
		StoreP:SetSize( MenuSheet:GetWide(), MenuSheet:GetTall() )
		MenuSheet:AddSheet( "Store", StoreP, "gui/silkicons/group", false, false, "Server's Item Store" )
		function StoreP:Think()
			local TAB = MenuSheet:GetActiveTab():GetValue()
			if !Store and TAB == "Store" then
				Store = vgui.Create( "InvStore", StoreP )
					Store:StretchToParent( 0, 0, 0, 0 )
			elseif Store and TAB != "Store" then
				Store:Remove()
				Store = nil
			end
		end
		
		
	local PPfriendsP = vgui.Create( "DPanel", MenuSheet )
	local PPfriends = nil
		PPfriendsP:SetSize( MenuSheet:GetWide(), MenuSheet:GetTall() )
		MenuSheet:AddSheet( "Prop Protection Friends", PPfriendsP, "gui/silkicons/group", false, false, "Friends menu for prop protection" )
		function PPfriendsP:Think()
			local TAB = MenuSheet:GetActiveTab():GetValue()
			if !PPfriends and TAB == "Prop Protection Friends" then
				PPfriends = vgui.Create( "PPfriends", PPfriendsP )
					PPfriends:StretchToParent( 0, 0, 0, 0 )
			elseif PPfriends and TAB != "Prop Protection Friends" then
				PPfriends:Remove()
				PPfriends = nil
			end
		end
		
		
	local HMenu = vgui.Create( "DPanel", MenuSheet )
	local HelpMenu = nil
		HMenu:SetSize( MenuSheet:GetWide(), MenuSheet:GetTall() )
		MenuSheet:AddSheet( "Help", HMenu, "gui/silkicons/user", false, false, "Help and Information" )
		function HMenu:Think()
			local TAB = MenuSheet:GetActiveTab():GetValue()
			if !HelpMenu and TAB == "Help" then
				HelpMenu = vgui.Create( "HelpMenu", HMenu )
					HelpMenu:StretchToParent( 0, 0, 0, 0 )
			elseif HelpMenu and TAB != "Help" then
				HelpMenu:Remove()
				HelpMenu = nil
			end
		end

end

function DoShowMenu()
	if CanF2 then
		PlayerMenu()
	else
		LocalPlayer():PrintMessage( HUD_PRINTTALK, "Wait for store information to be received before using the player menu." )
	end
end
concommand.Add( "ShowInventory", DoShowMenu )	//Change this to "Player Menu"

function ShowFirstHelp()
	
	local HFrame = vgui.Create( "DFrame" )	//Move this to the player.
		HFrame:SetSize( ScrW() * 0.75, ScrH() * 0.6 )
		HFrame:SetTitle( "Help Menu" )
		HFrame:SetDraggable( false )
		HFrame:SetSizable( false )
		HFrame:SetBackgroundBlur( true )
		HFrame:MakePopup()
			
	local HelpP = vgui.Create( "HelpMenu", HFrame )
		HelpP:StretchToParent( 2, 25, 2, 2 )

end
concommand.Add( "ShowFirstHelp", ShowFirstHelp )